#pragma once
#ifndef H265CODEC_H_
#define H265CODEC_H_

extern "C" {
#include <libavcodec/avcodec.h>
#include <libavutil/avutil.h>
#include <libswscale/swscale.h>
}

// #pragma comment(lib, "avcodec.lib")
// #pragma comment(lib, "avutil.lib")
// #pragma comment(lib, "swscale.lib")
class H265Codec
{
	int width_;
	int height_;
	AVPixelFormat fmt_;

	const AVCodecID codecId_ = AV_CODEC_ID_H265;
	const AVCodec* codec_ = nullptr;
	AVCodecContext* ctx_ = nullptr;
	AVPacket* pkt_ = nullptr;
	AVFrame* frame_ = nullptr;
	AVCodecParserContext* parser_ = nullptr;

	SwsContext* swsCtx_ = nullptr;

public:
	H265Codec(int width, int height, AVPixelFormat fmt, bool isDecode = true);
	~H265Codec();
	int decode(const unsigned char* buff, int len, unsigned char *outbuff, int linesize);
private:
	int convertScale(unsigned char* outbuff, int linesize);
};


#endif // !H265CODEC_H_

